﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SistemaComprasVentaYICHAN
{
    public partial class EliminarProvDLG : Form
    {
        public EliminarProvDLG()
        {
            InitializeComponent();
            this.textBox2.Enabled = false;
            this.textBox8.Enabled = false;
            this.textBox9.Enabled = false;
            this.textBox3.Enabled = false;
            this.textBox4.Enabled = false;
            this.textBox5.Enabled = false;
            this.textBox6.Enabled = false;
            this.textBox7.Enabled = false;
            this.comboBox1.Enabled = false;
            this.textBox10.Enabled = false;
            this.textBox11.Enabled = false;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != "")
            {
                GestorProveedor gP = GestorProveedor.getInstance;
                Proveedor p = gP.BuscarProveedor(this.textBox1.Text);
                if (p != null)
                {
                    this.textBox1.Text = p.getCodigo;
                    this.textBox2.Text = p.getRazonSocial;
                    this.textBox8.Text = p.getTelefonoContacto;
                    this.textBox9.Text = p.getCiudad;
                    this.textBox3.Text = p.getTelefonoEmpresa;
                    this.textBox4.Text = p.getRUC;
                    this.textBox5.Text = p.getEmail;
                    this.textBox6.Text = p.getDireccion;
                    this.textBox7.Text = p.getNombreContacto;
                    this.comboBox1.Text = p.getTipo;
                    this.textBox10.Text = p.getPais;
                    this.textBox11.Text = p.getDivisa;
                }
                else
                {
                    if (this.textBox1.Text != null && p == null) MessageBox.Show("no se ha encontrado el proveedor");
                    else MessageBox.Show("El ingreso de todos los campos es obligatorio");
                }

            }
            else
            {
                MessageBox.Show("Ingrese un codigo para buscar");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            GestorProveedor gP = GestorProveedor.getInstance;
            Proveedor p = gP.BuscarProveedor(this.textBox1.Text);
            if (p != null)
            {
                gP.EliminarProveedor(this.textBox1.Text);
            }
            MessageBox.Show("Se ELIMINO correctamente");
            this.Close();
        }

        private void EliminarProvDLG_Load(object sender, EventArgs e)
        {

        }

        private void EliminarProvDLG_Load_1(object sender, EventArgs e)
        {

        }
    }
}
